<template>
	<view class="cis">
		<view class="cisLi" v-for="(item, index) of list" :key="index">
			<view class="cisLiTop">
				<image class="cisLiTopImg" :src=item.storeLicense mode=""></image>
				<view class="cisLiTopRight">
					<view class="cisLiTopRight-title font_blod">
						{{item.storeName}}
					</view>
					<view class="cisLiTopRight-address">
						{{item.storeDetailAddress}}
					</view>
					<view class="cisLiTopRight-num">
						鉴定产品数量：{{item.appraisalNum}}个
					</view>
				</view>
			</view>
			<view class="cisLiBtm font_blod" v-if="item.isAppraisal == 1">
				<view class="cisLiBtmLeft" @click="cli_close(item)">
					关闭鉴定权
				</view>
				<view class="cisLiBtmRight" @click="cli_next(item, index)">
					匹配鉴定权
				</view>
			</view>
			<view class="cisLiBtm font_blod" v-if="item.isAppraisal == 0">
				<view class="cisLiBtmLeftText">
					鉴定权关闭
				</view>
				<view class="cisLiBtmRightTwo" @click="cli_open(item)">
					开启鉴定权
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import allapi from '../api/index.js'
	export default {
		data() {
			return {
				agentId: uni.getStorageSync('agentId'),
				list: []
			}
		},
		mounted() {
			this.getPartsStoreList()
		},
		methods: {
			// 点击匹配鉴定权
			cli_next (item, index) {
				let id = item.id
				uni.navigateTo({
					url: '/pages/centerInviteSubsideAuthenticate/centerInviteSubsideAuthenticate?id=' + id
				})
			},
			// 获取配件店列表
			getPartsStoreList () {
				uni.request({
					url: allapi.getPartsStoreList,
					data: {
						agentId: this.agentId
					},
					success: (res) => {
						console.log(res);
						this.list = res.data.data
					}
				})
			},
			// 关闭鉴定权
			cli_close (item) {
				this.updateIsAppraisal(item.id, 0)
			},
			// 打开鉴定权
			cli_open (item) {
				this.updateIsAppraisal(item.id, 1)
			},
			// 修改鉴定权限
			updateIsAppraisal (id,isAppraisal) {
				uni.request({
					url: allapi.updateIsAppraisal,
					data: {
						id: id,
						isAppraisal: isAppraisal
					},
					success: (res) => {
						console.log(res);
						this.getPartsStoreList()
					}
				})
			},
		}
	}
</script>

<style scoped>
	.cis {
		width: 100%;
		height: 100%;
		position: absolute;
		background: linear-gradient(180deg, #FDD194 0%, #F6F6F6 100%);
		left: 0;
		top: 0;
		overflow: auto;
	}
	.cisLi {
		margin: 24rpx;
		background: #FFFFFF;
		border-radius: 16rpx;
		padding: 40rpx 32rpx;
	}
	.cisLiTop {
		display: flex;
	}
	.cisLiTopImg {
		width: 112rpx;
		height: 112rpx;
		border-radius: 50%;
		background: #EEEEEE;
	}
	.cisLiTopRight {
		margin-left: 28rpx;
		flex: 1;
	}
	.cisLiTopRight-title {
		font-size: 32rpx;
		color: #333333;
		line-height: 44rpx;
	}
	.cisLiTopRight-address {
		margin-top: 16rpx;
		font-size: 28rpx;
		color: #666666;
		line-height: 40rpx;
	}
	.cisLiTopRight-num {
		font-size: 24rpx;
		color: #333333;
		margin-top: 16rpx;
	}
	.cisLiBtm {
		display: flex;
		margin-top: 40rpx;
		align-items: center;
		justify-content: space-between;
	}
	.cisLiBtmLeft {
		width: 232rpx;
		height: 72rpx;
		line-height: 72rpx;
		text-align: center;
		border-radius: 36rpx;
		border: 2rpx solid #333333;
		font-size: 24rpx;
		color: #333333;
	}
	.cisLiBtmLeftText {
		color: #E22F48;
		font-size: 24rpx;
	}
	.cisLiBtmRight {
		width: 236rpx;
		height: 72rpx;
		line-height: 72rpx;
		text-align: center;
		background: linear-gradient(to bottom, #F27E75, #E22F48);
		font-size: 28rpx;
		color: #FFFFFF;
		border-radius: 40rpx;
	}
	.cisLiBtmRightTwo {
		width: 236rpx;
		height: 72rpx;
		line-height: 72rpx;
		text-align: center;
		background: linear-gradient(180deg, #F8BA70 0%, #FB862F 100%);
		font-size: 28rpx;
		color: #FFFFFF;
		border-radius: 40rpx;
	}
</style>
